Convex Hull Algorithms
   HOME

TheInfoList



OR:

Algorithms that construct convex hulls of various objects have a broad range of applications in
mathematics Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
and
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied science, practical discipli ...
. In
computational geometry Computational geometry is a branch of computer science devoted to the study of algorithms which can be stated in terms of geometry. Some purely geometrical problems arise out of the study of computational geometric algorithms, and such problems ar ...
, numerous algorithms are proposed for computing the convex hull of a finite set of points, with various computational complexities. Computing the convex hull means that a non-ambiguous and efficient representation of the required convex shape is constructed. The complexity of the corresponding algorithms is usually estimated in terms of ''n'', the number of input points, and sometimes also in terms of ''h'', the number of points on the convex hull.


Planar case

Consider the general case when the input to the algorithm is a finite unordered set of points on a Cartesian plane. An important special case, in which the points are given in the order of traversal of a simple polygon's boundary, is described later in a separate subsection. If not all points are on the same line, then their convex hull is a
convex polygon In geometry, a convex polygon is a polygon that is the boundary of a convex set. This means that the line segment between two points of the polygon is contained in the union of the interior and the boundary of the polygon. In particular, it is a ...
whose vertices are some of the points in the input set. Its most common representation is the list of its vertices ordered along its boundary clockwise or counterclockwise. In some applications it is convenient to represent a convex polygon as an intersection of a set of half-planes.


Lower bound on computational complexity

For a finite set of points in the plane the lower bound on the computational complexity of finding the convex hull represented as a convex polygon is easily shown to be the same as for
sorting Sorting refers to ordering data in an increasing or decreasing manner according to some linear relationship among the data items. # ordering: arranging items in a sequence ordered by some criterion; # categorizing: grouping items with similar pro ...
using the following reduction. For the set x_1,\dots,x_n numbers to sort consider the set (x_1, x^2_1),\dots,(x_n, x^2_n) of points in the plane. Since they lie on a
parabola In mathematics, a parabola is a plane curve which is mirror-symmetrical and is approximately U-shaped. It fits several superficially different mathematical descriptions, which can all be proved to define exactly the same curves. One descript ...
, which is a convex curve it is easy to see that the vertices of the convex hull, when traversed along the boundary, produce the sorted order of the numbers x_1,\dots,x_n. Clearly,
linear time In computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations performed by ...
is required for the described transformation of numbers into points and then extracting their sorted order. Therefore, in the general case the convex hull of ''n'' points cannot be computed more quickly than sorting. The standard Ω(''n'' log ''n'') lower bound for sorting is proven in the
decision tree model In computational complexity the decision tree model is the model of computation in which an algorithm is considered to be basically a decision tree, i.e., a sequence of ''queries'' or ''tests'' that are done adaptively, so the outcome of the pre ...
of computing, in which only numerical comparisons but not arithmetic operations can be performed; however, in this model, convex hulls cannot be computed at all. Sorting also requires Ω(''n'' log ''n'') time in the
algebraic decision tree In computational complexity the decision tree model is the model of computation in which an algorithm is considered to be basically a decision tree, i.e., a sequence of ''queries'' or ''tests'' that are done adaptively, so the outcome of the pre ...
model of computation, a model that is more suitable for convex hulls, and in this model convex hulls also require Ω(''n'' log ''n'') time.Preparata, Shamos, ''Computational Geometry'', Chapter "Convex Hulls: Basic Algorithms" However, in models of computer arithmetic that allow numbers to be sorted more quickly than ''O''(''n'' log ''n'') time, for instance by using
integer sorting In computer science, integer sorting is the algorithmic problem of sorting a collection of data values by integer keys. Algorithms designed for integer sorting may also often be applied to sorting problems in which the keys are floating point numb ...
algorithms, planar convex hulls can also be computed more quickly: the
Graham scan Graham's scan is a method of finding the convex hull of a finite set of points in the plane with time complexity O(''n'' log ''n''). It is named after Ronald Graham, who published the original algorithm in 1972. The algorithm finds all vertices ...
algorithm for convex hulls consists of a single sorting step followed by a linear amount of additional work.


Optimal output-sensitive algorithms

As stated above, the complexity of finding a convex hull as a function of the input size ''n'' is lower bounded by Ω(''n'' log ''n''). However, the complexity of some convex hull algorithms can be characterized in terms of both input size ''n'' and the output size ''h'' (the number of points in the hull). Such algorithms are called
output-sensitive algorithm In computer science, an output-sensitive algorithm is an algorithm whose running time depends on the size of the output, instead of, or in addition to, the size of the input. For certain problems where the output size varies widely, for example fro ...
s. They may be asymptotically more efficient than Θ(''n'' log ''n'') algorithms in cases when ''h'' = ''o''(''n''). The lower bound on worst-case running time of output-sensitive convex hull algorithms was established to be Ω(''n'' log ''h'') in the planar case. There are several algorithms which attain this optimal
time complexity In computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations performed by t ...
. The earliest one was introduced by Kirkpatrick and Seidel in 1986 (who called it "the
ultimate convex hull algorithm Ultimate or Ultimates may refer to: Arts, entertainment, and media Music Albums * ''Ultimate'' (Jolin Tsai album) * ''Ultimate'' (Pet Shop Boys album) *''Ultimate!'', an album by The Yardbirds *'' The Ultimate (Bryan Adams Album)'', a compilati ...
"). A much simpler algorithm was developed by Chan in 1996, and is called
Chan's algorithm In computational geometry, Chan's algorithm, named after Timothy M. Chan, is an optimal output-sensitive algorithm to compute the convex hull of a set P of n points, in 2- or 3-dimensional space. The algorithm takes O(n \log h) time, where h is ...
.


Algorithms

Known convex hull algorithms are listed below, ordered by the date of first publication. Time complexity of each algorithm is stated in terms of the number of inputs points ''n'' and the number of points on the hull ''h''. Note that in the worst case ''h'' may be as large as ''n''. *
Gift wrapping Gift wrapping is the act of enclosing a gift in some sort of material. Wrapping paper is a kind of paper designed for gift wrapping. An alternative to gift wrapping is using a gift box or bag. A wrapped or boxed gift may be held closed with ri ...
, a.k.a. Jarvis march — ''O''(''nh'')
One of the simplest (although not the most time efficient in the worst case) planar algorithms. Created independently by Chand & Kapur in 1970 and R. A. Jarvis in 1973. It has O(''nh'')
time complexity In computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations performed by t ...
, where ''n'' is the number of points in the set, and ''h'' is the number of points in the hull. In the worst case the complexity is Θ(''n2''). *
Graham scan Graham's scan is a method of finding the convex hull of a finite set of points in the plane with time complexity O(''n'' log ''n''). It is named after Ronald Graham, who published the original algorithm in 1972. The algorithm finds all vertices ...
— ''O''(''n'' log ''n'')
A slightly more sophisticated, but much more efficient algorithm, published by
Ronald Graham Ronald Lewis Graham (October 31, 1935July 6, 2020) was an American mathematician credited by the American Mathematical Society as "one of the principal architects of the rapid development worldwide of discrete mathematics in recent years". He ...
in 1972. If the points are already sorted by one of the coordinates or by the angle to a fixed vector, then the algorithm takes O(''n'') time. *
Quickhull Quickhull is a method of computing the convex hull of a finite set of points in ''n''-dimensional space. It uses a divide and conquer approach similar to that of quicksort, from which its name derives. Its worst case time complexity for 2-dimensio ...

Created independently in 1977 by W. Eddy and in 1978 by A. Bykat. Just like the
quicksort Quicksort is an efficient, general-purpose sorting algorithm. Quicksort was developed by British computer scientist Tony Hoare in 1959 and published in 1961, it is still a commonly used algorithm for sorting. Overall, it is slightly faster than ...
algorithm, it has the expected time complexity of ''O''(''n'' log ''n''), but may degenerate to ''O''(''n''2) in the worst case. * Divide and conquer — ''O''(''n'' log ''n'')
Another O(''n'' log ''n'') algorithm, published in 1977 by Preparata and Hong. This algorithm is also applicable to the three dimensional case. * Monotone chain, a.k.a. Andrew's algorithm— ''O''(''n'' log ''n'')
Published in 1979 by A. M. Andrew. The algorithm can be seen as a variant of Graham scan which sorts the points lexicographically by their coordinates. When the input is already sorted, the algorithm takes ''O''(''n'') time. * Incremental convex hull algorithm — ''O''(''n'' log ''n'')
Published in 1984 by Michael Kallay. *
Kirkpatrick–Seidel algorithm The Kirkpatrick–Seidel algorithm, proposed by its authors as a potential "ultimate planar convex hull algorithm", is an algorithm for computing the convex hull of a set of points in the plane, with \mathcal(n \log h) time complexity, where n is th ...
— ''O''(''n'' log ''h'')
The first optimal output-sensitive algorithm. It modifies the divide and conquer algorithm by using the technique of marriage-before-conquest and low-dimensional linear programming. Published by Kirkpatrick and Seidel in 1986. *
Chan's algorithm In computational geometry, Chan's algorithm, named after Timothy M. Chan, is an optimal output-sensitive algorithm to compute the convex hull of a set P of n points, in 2- or 3-dimensional space. The algorithm takes O(n \log h) time, where h is ...
— ''O''(''n'' log ''h'')
A simpler optimal output-sensitive algorithm created by Chan in 1996. It combines gift wrapping with the execution of an ''O''(''n'' log ''n'') algorithm (such as Graham scan) on small subsets of the input.


Akl–Toussaint heuristic

The following simple heuristic is often used as the first step in implementations of convex hull algorithms to improve their performance. It is based on the efficient convex hull algorithm by
Selim Akl Selim G. Akl (Ph.D., McGill University, 1978) is a professor at Queen's University in the Queen's School of Computing, where he leads the Parallel and Unconventional Computation Group. His research interests are primarily in the area of algorithm ...
and G. T. Toussaint, 1978. The idea is to quickly exclude many points that would not be part of the convex hull anyway. This method is based on the following idea. Find the two points with the lowest and highest x-coordinates, and the two points with the lowest and highest y-coordinates. (Each of these operations takes O(''n'').) These four points form a convex quadrilateral, and all points that lie in this quadrilateral (except for the four initially chosen vertices) are not part of the convex hull. Finding all of these points that lie in this quadrilateral is also O(''n''), and thus, the entire operation is O(''n''). Optionally, the points with smallest and largest sums of x- and y-coordinates as well as those with smallest and largest differences of x- and y-coordinates can also be added to the quadrilateral, thus forming an irregular convex octagon, whose insides can be safely discarded. If the points are random variables, then for a narrow but commonly encountered class of probability density functions, this ''throw-away'' pre-processing step will make a convex hull algorithm run in linear expected time, even if the worst-case complexity of the convex hull algorithm is quadratic in ''n''.


On-line and dynamic convex hull problems

The discussion above considers the case when all input points are known in advance. One may consider two other settings. * Online convex hull problem: Input points are obtained sequentially one by one. After each point arrives on input, the convex hull for the pointset obtained so far must be efficiently computed. *
Dynamic convex hull The dynamic convex hull problem is a class of dynamic problems in computational geometry. The problem consists in the maintenance, i.e., keeping track, of the convex hull for input data undergoing a sequence of discrete changes, i.e., when input ...
maintenance: The input points may be sequentially inserted or deleted, and the convex hull must be updated after each insert/delete operation. Insertion of a point may increase the number of vertices of a convex hull at most by 1, while deletion may convert an ''n''-vertex convex hull into an ''n-1''-vertex one. The online version may be handled with O(log ''n'') per point, which is asymptotically optimal. The dynamic version may be handled with O(log2 ''n'') per operation.


Simple polygon

The convex hull of a
simple polygon In geometry, a simple polygon is a polygon that does not intersect itself and has no holes. That is, it is a flat shape consisting of straight, non-intersecting line segments or "sides" that are joined pairwise to form a single closed path. If ...
is divided by the polygon into pieces, one of which is the polygon itself and the rest are ''pockets'' bounded by a piece of the polygon boundary and a single hull edge. Although many algorithms have been published for the problem of constructing the convex hull of a simple polygon, nearly half of them are incorrect. McCallum and Avis provided the first correct algorithm. A later simplification by and uses only a single stack data structure. Their algorithm traverses the polygon clockwise, starting from its leftmost vertex. As it does, it stores a convex sequence of vertices on the stack, the ones that have not yet been identified as being within pockets. At each step, the algorithm follows a path along the polygon from the stack top to the next vertex that is not in one of the two pockets adjacent to the stack top. Then, while the top two vertices on the stack together with this new vertex are not in convex position, it pops the stack, before finally pushing the new vertex onto the stack. When the clockwise traversal reaches the starting point, the algorithm returns the sequence of stack vertices as the hull.


Higher dimensions

A number of algorithms are known for the three-dimensional case, as well as for arbitrary dimensions.
Chan's algorithm In computational geometry, Chan's algorithm, named after Timothy M. Chan, is an optimal output-sensitive algorithm to compute the convex hull of a set P of n points, in 2- or 3-dimensional space. The algorithm takes O(n \log h) time, where h is ...
is used for dimensions 2 and 3, and
Quickhull Quickhull is a method of computing the convex hull of a finite set of points in ''n''-dimensional space. It uses a divide and conquer approach similar to that of quicksort, from which its name derives. Its worst case time complexity for 2-dimensio ...
is used for computation of the convex hull in higher dimensions. For a finite set of points, the convex hull is a
convex polyhedron A convex polytope is a special case of a polytope, having the additional property that it is also a convex set contained in the n-dimensional Euclidean space \mathbb^n. Most texts. use the term "polytope" for a bounded convex polytope, and the wo ...
in three dimensions, or in general a convex polytope for any number of dimensions, whose vertices are some of the points in the input set. Its representation is not so simple as in the planar case, however. In higher dimensions, even if the vertices of a convex polytope are known, construction of its
face The face is the front of an animal's head that features the eyes, nose and mouth, and through which animals express many of their emotions. The face is crucial for human identity, and damage such as scarring or developmental deformities may aff ...
s is a non-trivial task, as is the dual problem of constructing the vertices given the faces. The size of the output face information may be exponentially larger than the size of the input vertices, and even in cases where the input and output are both of comparable size the known algorithms for high-dimensional convex hulls are not output-sensitive due both to issues with degenerate inputs and with intermediate results of high complexity..


See also

*
Orthogonal convex hull In geometry, a set is defined to be orthogonally convex if, for every line that is parallel to one of standard basis vectors, the intersection of with is empty, a point, or a single segment. The term "orthogonal" refers to corresponding C ...


References


Further reading

*
Thomas H. Cormen Thomas H. Cormen is the co-author of ''Introduction to Algorithms'', along with Charles Leiserson, Ron Rivest, and Cliff Stein. In 2013, he published a new book titled '' Algorithms Unlocked''. He is a professor of computer science at Dartmout ...
,
Charles E. Leiserson Charles Eric Leiserson is a computer scientist, specializing in the theory of parallel computing and distributed computing, and particularly practical applications thereof. As part of this effort, he developed the Cilk multithreaded language. ...
,
Ronald L. Rivest Ronald Linn Rivest (; born May 6, 1947) is a cryptographer and an Institute Professor at MIT. He is a member of MIT's Department of Electrical Engineering and Computer Science (EECS) and a member of MIT's Computer Science and Artificial Inte ...
, and
Clifford Stein Clifford Seth Stein (born December 14, 1965), a computer scientist, is a professor of industrial engineering and operations research at Columbia University in New York, NY, where he also holds an appointment in the Department of Computer Scien ...
. ''
Introduction to Algorithms ''Introduction to Algorithms'' is a book on computer programming by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The book has been widely used as the textbook for algorithms courses at many universities and is co ...
'', Second Edition. MIT Press and McGraw-Hill, 2001. . Section 33.3: Finding the convex hull, pp. 947–957. *
Franco P. Preparata Franco P. Preparata is a computer scientist, the An Wang Professor, Emeritus, of Computer Science at Brown University. He is best known for his 1985 book "Computational Geometry: An Introduction" into which he blended salient parts of M. I. ...
, S.J. Hong. ''Convex Hulls of Finite Sets of Points in Two and Three Dimensions'', Commun. ACM, vol. 20, no. 2, pp. 87–93, 1977. * Section 1.1: An Example: Convex Hulls (describes classical algorithms for 2-dimensional convex hulls). Chapter 11: Convex Hulls: pp. 235–250 (describes a randomized algorithm for 3-dimensional convex hulls due to Clarkson and Shor).


External links

* {{MathWorld, urlname=ConvexHull, title=Convex Hull
2D, 3D, and dD Convex Hull
in CGAL, the Computational Geometry Algorithms Library
Qhull code for Convex Hull, Delaunay Triangulation, Voronoi Diagram, and Halfspace Intersection


Jarvis, Graham, Quick (divide and conquer) and Chan algorithms
Gift wrapping algorithm in C#